<?php
	//the uploaded file information is available via $_FILES superglobal array
	echo  "<pre>";
		print_r($_FILES);
	echo  "</pre>";
        //getting extention of uploaded file
	//$extention = substr($_FILES['userfile']['name'],-3)."<br/>";

	//move_uploaded_file places the uploaded file to place of our choice
	//use as: move_uploaded_file (source file i.e uploaded file's tmp_name, destination_file_path);

	//folder name where we are going to store our files
	//don't forget the dot --> .
	$upload_dir = './user_uploads';

	//tmp_name holds temporary file for uploaded file
	$source_file = $_FILES['userfile']['tmp_name'];

	//the 'name' key of the array holds original filename
	//we can use original file name here as our destination filename. it will be saved inside our upload directory
	$destination_file = $_FILES['userfile']['name'];
        //if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploa_dir)) {

	if (move_uploaded_file($source_file, $upload_dir."/". $destination_file)) {
        echo "Received {$_FILES['userfile']['name']} - its size is {$_FILES['userfile']['size']}";
    } else {
        echo "Upload failed!";
    }


?>